﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SHJunketingBLL;
using SHJunketingModel;

public partial class Admin_UserManagement_EditRoleInfo : System.Web.UI.Page
{
    public string formType = "";

    public int id = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] == null || Request.QueryString["id"] == "")
        {
            formType = "new";
        }
        else 
        {
            formType = "edit";
        }

        try
        {
            id = Convert.ToInt32(Request.QueryString["id"]);
        }
        catch
        {
            id = 0;
        }

        if (!IsPostBack) 
        {
                C_YuyueType YuyueType = C_YuyueTypeManage.GetYuyueTypeByID(id);

                if (YuyueType == null)
                {
                    YuyueType = new C_YuyueType();
                    YuyueType.Fenlei = "";
                    YuyueType.Starttime = "";
                    YuyueType.Endtime = "";
                }

                this.txtFenlei.Text = YuyueType.Fenlei;
                this.txtStartTime.Text = YuyueType.Starttime;
                this.txtEndTime.Text = YuyueType.Endtime;
         } 
     }


    //修改
    protected void btnEdit_Click(object sender, EventArgs e)
    {
            if (txtFenlei.Text.Length > 10)
            {
                Web.CommFun.Show_Msg("预约方式不能超过10！");
                return;
            }

            if (txtStartTime.Text.Length > 10)
            {
                Web.CommFun.Show_Msg("开始时间不能超过10！");
                return;
            }

            if (txtEndTime.Text.Length > 10)
            {
                Web.CommFun.Show_Msg("结束时间不能超过10！");
                return;
            }

            C_YuyueType YuyueType = new C_YuyueType();
            YuyueType.ID  = id;
            YuyueType.Fenlei = txtFenlei.Text.Trim();
            YuyueType.Starttime = txtStartTime.Text.Trim();
            YuyueType.Endtime = txtEndTime.Text.Trim();

            if (formType == "edit")
            {
                C_YuyueTypeManage.ModifyYuyueType(YuyueType);
                Web.CommFun.Show_Msg("修改成功！", "YuyueType.aspx");
            }
            else 
            {
                C_YuyueTypeManage.AddC_YuyueTypeInfo(YuyueType);
                Web.CommFun.Show_Msg("添加成功！", "YuyueType.aspx");
            }
            

    }
}
